package com.tg.sieve_data.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tg.sieve_data.entity.Region;
import com.tg.sieve_data.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/region")
public class RegionController {
    @Autowired
    private RegionService regionService;

    @RequestMapping("/list")
    public Object list() {
        return regionService.list(new QueryWrapper<Region>().orderByAsc("id"));
    }

    @RequestMapping("/tree")
    public Object getTreeData() {
        return regionService.getTreeData();
    }

    @RequestMapping("/children")
    public Object getChildren(Integer parentId) {
        return regionService.getByParentId(parentId);
    }
}
